package org.opens.serviceTask;

import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class MyServiceTask implements JavaDelegate {

    @Autowired
    private TaskService taskService;

    @Autowired
    private RuntimeService runtimeService;

    @Override
    public void execute(DelegateExecution execution) {
        System.out.println("========MyServiceTask==========");
        System.out.println("execution = " + execution);
        System.out.println("流程实例id: " + execution.getProcessInstanceId());

        // 可以获取到创建流程实例时传入的变量
        Map<String, Object> variables = execution.getVariables();
        System.out.println("变量: " + variables);
    }

}
